<template>
  <p>age: {{ age }} num: {{ num }}</p>
  <button @click="handleClick">click</button>
</template>

<script>
import { watch, ref } from 'vue'
export default {
  name: 'App',
  setup() {
    const age = ref(18)
    const num = ref(0)

    const handleClick = () => {
      // age.value++
      num.value++
    }
    // 数组里面是 ref 数据
    watch([age, num], (newValue, oldValue) => {
      console.log(newValue, oldValue)
    }, {
      immediate: true
    })

    return { age, num, handleClick }
  },
}
</script>